import { Ref } from 'vue';
import { dateUtil } from '/@/utils/dateUtil';
import { BasicColumn, FormSchema } from '/@/components/Table';
import { useI18n } from '/@/hooks/web/useI18n';
import { ActionEnum } from '/@/enums/commonEnum';
import { FormSchemaExt } from '/@/api/lamp/common/formValidateService';

const { t } = useI18n();
// 列表页字段
export const columns = (): BasicColumn[] => {
  return [
    {
      title: t('david-care.david-care.bInpatientDiagnosis.diagnosisTime'),
      dataIndex: 'diagnosisTime',
    },
    {
      title: t('david-care.david-care.bInpatientDiagnosis.diagnosisContent'),
      dataIndex: 'diagnosisContent',
    },
    {
      title: t('david-care.david-care.bInpatientDiagnosis.createTime'),
      dataIndex: 'createTime',
    },
    {
      title: t('david-care.david-care.bInpatientDiagnosis.patientIdent'),
      dataIndex: 'patientIdent',
    },
    {
      title: t('david-care.david-care.bInpatientDiagnosis.hospitalNumber'),
      dataIndex: 'hospitalNumber',
    },
    {
      title: t('david-care.david-care.bInpatientDiagnosis.diagnosisDoctorName'),
      dataIndex: 'diagnosisDoctorName',
    },
    {
      title: t('david-care.david-care.bInpatientDiagnosis.diagnosisType'),
      dataIndex: 'diagnosisType',
    },
    {
      title: t('david-care.david-care.bInpatientDiagnosis.diagnosisTypeName'),
      dataIndex: 'diagnosisTypeName',
    },
    {
      title: t('lamp.common.createdTime'),
      dataIndex: 'createdTime',
      sorter: true,
      width: 180,
    },
  ];
};

export const searchFormSchema = (): FormSchema[] => {
  return [
    {
      label: t('david-care.david-care.bInpatientDiagnosis.diagnosisTime'),
      field: 'diagnosisTime',
      component: 'DatePicker',
      componentProps: {
        format: 'YYYY-MM-DD HH:mm:ss',
        valueFormat: 'YYYY-MM-DD HH:mm:ss',
        showTime: { defaultValue: dateUtil('00:00:00', 'HH:mm:ss') },
      },
      colProps: { span: 6 },
    },
    {
      label: t('david-care.david-care.bInpatientDiagnosis.diagnosisContent'),
      field: 'diagnosisContent',
      component: 'Input',
      colProps: { span: 6 },
    },
    {
      label: t('david-care.david-care.bInpatientDiagnosis.createTime'),
      field: 'createTime',
      component: 'DatePicker',
      componentProps: {
        format: 'YYYY-MM-DD HH:mm:ss',
        valueFormat: 'YYYY-MM-DD HH:mm:ss',
        showTime: { defaultValue: dateUtil('00:00:00', 'HH:mm:ss') },
      },
      colProps: { span: 6 },
    },
    {
      label: t('david-care.david-care.bInpatientDiagnosis.patientIdent'),
      field: 'patientIdent',
      component: 'Input',
      colProps: { span: 6 },
    },
    {
      label: t('david-care.david-care.bInpatientDiagnosis.hospitalNumber'),
      field: 'hospitalNumber',
      component: 'Input',
      colProps: { span: 6 },
    },
    {
      label: t('david-care.david-care.bInpatientDiagnosis.diagnosisDoctorName'),
      field: 'diagnosisDoctorName',
      component: 'Input',
      colProps: { span: 6 },
    },
    {
      label: t('david-care.david-care.bInpatientDiagnosis.diagnosisType'),
      field: 'diagnosisType',
      component: 'Input',
      colProps: { span: 6 },
    },
    {
      label: t('david-care.david-care.bInpatientDiagnosis.diagnosisTypeName'),
      field: 'diagnosisTypeName',
      component: 'Input',
      colProps: { span: 6 },
    },
    {
      field: 'createTimeRange',
      label: t('lamp.common.createdTime'),
      component: 'RangePicker',
      colProps: { span: 6 },
    },
  ];
};

// 编辑页字段
export const editFormSchema = (_type: Ref<ActionEnum>): FormSchema[] => {
  return [
    {
      field: 'id',
      label: 'ID',
      component: 'Input',
      show: false,
    },
    {
      label: t('david-care.david-care.bInpatientDiagnosis.diagnosisTime'),
      field: 'diagnosisTime',
      component: 'DatePicker',
      componentProps: {
        format: 'YYYY-MM-DD HH:mm:ss',
        valueFormat: 'YYYY-MM-DD HH:mm:ss',
        showTime: { defaultValue: dateUtil('00:00:00', 'HH:mm:ss') },
      },
    },
    {
      label: t('david-care.david-care.bInpatientDiagnosis.diagnosisContent'),
      field: 'diagnosisContent',
      component: 'Input',
    },
    {
      label: t('david-care.david-care.bInpatientDiagnosis.createTime'),
      field: 'createTime',
      component: 'DatePicker',
      defaultValue: 'CURRENT_TIMESTAMP',
      componentProps: {
        format: 'YYYY-MM-DD HH:mm:ss',
        valueFormat: 'YYYY-MM-DD HH:mm:ss',
        showTime: { defaultValue: dateUtil('00:00:00', 'HH:mm:ss') },
      },
    },
    {
      label: t('david-care.david-care.bInpatientDiagnosis.patientIdent'),
      field: 'patientIdent',
      component: 'Input',
    },
    {
      label: t('david-care.david-care.bInpatientDiagnosis.hospitalNumber'),
      field: 'hospitalNumber',
      component: 'Input',
    },
    {
      label: t('david-care.david-care.bInpatientDiagnosis.diagnosisDoctorName'),
      field: 'diagnosisDoctorName',
      component: 'Input',
    },
    {
      label: t('david-care.david-care.bInpatientDiagnosis.diagnosisType'),
      field: 'diagnosisType',
      component: 'Input',
    },
    {
      label: t('david-care.david-care.bInpatientDiagnosis.diagnosisTypeName'),
      field: 'diagnosisTypeName',
      component: 'Input',
    },
  ];
};

// 前端自定义表单验证规则
export const customFormSchemaRules = (_): Partial<FormSchemaExt>[] => {
  return [];
};
